-
Notifications
You must be signed in to change notification settings - Fork 674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
deps: update tempfile to 3 #900
Conversation
I'm not sure if you want to have prefixed directories, but kept it as it was. |
(except for the doctest for simplicity sake) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, it looks good. But I think we should be consistent about using either anonymous or named temporary files/directories. The preference should probably be anonymous tempfile > named tempfile > anonymous tempdir > named tempdir.
test/sys/test_socket.rs
Outdated
|
||
let tempdir = TempDir::new("test_getsockname").unwrap(); | ||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this test work even with an anonymous tempdir, like this? I think anonymous tempdirs still have names; only anonymous tempfiles don't.
let tempdir = TempDir::new();
let sockname = tempdir.path().join("sock")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it should, just wanted to keep prefixes as it was in original code. If this is not needed, I'm going to drop it.
@@ -114,7 +113,10 @@ fn test_pwrite() { | |||
fn test_pread() { | |||
use std::io::Write; | |||
|
|||
let tempdir = TempDir::new("nix-test_pread").unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, I think you can use an anonymous temp file like this. Less code, and no Rust cleanup required. test_pwrite
already does just this.
let mut file = tempfile().unwrap();
@ignatenkobrain friendly ping |
sorry for delay, was busy with $dayjob. Updating now. |
rebased + updated. |
Looks like you have a basic syntax error. Did you test locally before pushing? |
@asomers passes now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @Susurrus any feelings?
I'd agree with consistently using anonymous directories. I'd also suggest we be consistent with using |
@Susurrus does that mean you don't approve? If so, please give a negative review to indicate that the PR still needs some work. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have consistent usages of tempdir()
, and I don't think we need to prefix or do any real error checking on this. If temp directories are failing, we likely have bigger issues here.
test/test_fcntl.rs
Outdated
@@ -30,7 +29,9 @@ fn test_openat() { | |||
|
|||
#[test] | |||
fn test_readlink() { | |||
let tempdir = TempDir::new("nix-test_readdir") | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_mount.rs
Outdated
@@ -32,7 +32,9 @@ exit 23"; | |||
|
|||
const NONE: Option<&'static [u8]> = None; | |||
pub fn test_mount_tmpfs_without_flags_allows_rwx() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_mount.rs
Outdated
@@ -89,7 +91,9 @@ exit 23"; | |||
} | |||
|
|||
pub fn test_mount_rdonly_disallows_write() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_mount.rs
Outdated
@@ -107,7 +111,9 @@ exit 23"; | |||
} | |||
|
|||
pub fn test_mount_noexec_disallows_exec() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_mount.rs
Outdated
@@ -146,12 +152,16 @@ exit 23"; | |||
} | |||
|
|||
pub fn test_mount_bind() { | |||
let tempdir = TempDir::new("nix-test_mount") | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_stat.rs
Outdated
@@ -106,7 +115,10 @@ fn test_stat_fstat_lstat() { | |||
|
|||
#[test] | |||
fn test_fchmod() { | |||
let tempdir = TempDir::new("nix-test_fchmod").unwrap(); | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_stat.rs
Outdated
@@ -128,7 +140,10 @@ fn test_fchmod() { | |||
|
|||
#[test] | |||
fn test_fchmodat() { | |||
let tempdir = TempDir::new("nix-test_fchmodat").unwrap(); | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_unistd.rs
Outdated
@@ -84,7 +81,10 @@ fn test_mkstemp_directory() { | |||
|
|||
#[test] | |||
fn test_mkfifo() { | |||
let tempdir = TempDir::new("nix-test_mkfifo").unwrap(); | |||
let tempdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_unistd.rs
Outdated
@@ -286,7 +286,10 @@ fn test_fchdir() { | |||
#[allow(unused_variables)] | |||
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test"); | |||
|
|||
let tmpdir = TempDir::new("test_fchdir").unwrap(); | |||
let tmpdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
test/test_unistd.rs
Outdated
@@ -302,7 +305,10 @@ fn test_getcwd() { | |||
#[allow(unused_variables)] | |||
let m = ::CWD_MTX.lock().expect("Mutex got poisoned by another test"); | |||
|
|||
let tmpdir = TempDir::new("test_getcwd").unwrap(); | |||
let tmpdir = tempfile::Builder::new() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just tempfile::tempdir().unwrap();
should be fine.
fd85572
to
9e1caa4
Compare
Updated to address all points from @Susurrus |
Test failures on i386 freebsd 11. Travis reported a spurious failure I'm rerunning. |
test/sys/test_socket.rs
Outdated
@@ -90,9 +90,9 @@ pub fn test_abstract_uds_addr() { | |||
pub fn test_getsockname() { | |||
use nix::sys::socket::{socket, AddressFamily, SockType, SockFlag}; | |||
use nix::sys::socket::{bind, SockAddr}; | |||
use tempdir::TempDir; | |||
use tempfile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't necessary, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Susurrus I don't understand what you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, don't know what I was talking about here. But since none of these are conditionally compiled I'd suggest we put a single use
statement at the top of the file and get rid of all of the additional ones.
It seems like
Is it possible to bump the required rust version for nix to 1.22 or higher? I'm also interested in having this in for #930 |
There's nothing special about 1.20.0. You can bump the minimum compiler version if it's for a good reason. |
Correct. I have to update the buildbots outside of Github. I'll do that after you settle on a Rustc version. Will it be 1.22.0 or 1.24.1? |
These changes all look good to me. Just needs the version stuff sorted out. I will say that I'd like to bump the version as little as possible. If 1.22.0 works, I'd prefer we use that. |
I believe the buildbots have been updated to 1.22.1, @ignatenkobrain will you have time to work on this in the near future? We'd like to get this merged before some other PRs. |
b8e8454
to
6ccfc37
Compare
we should be all good. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a general remark, I would try to use tempdir()
and tempfile()
functions wherever possible. They should be imported with use tempfile::{tempdir, tempfile}
(whichever is required). This would make the whole thing more consistent and there is no need to import self
. The only exception is the NamedTempFile
that can't be replaced by tempfile()
.
src/unistd.rs
Outdated
/// | ||
/// fn main() { | ||
/// let tmp_dir1 = TempDir::new("test_mkdir").unwrap(); | ||
/// let tmp_dir1 = TempDir::new().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tempfile::tempdir().unwrap()
here
src/unistd.rs
Outdated
/// extern crate nix; | ||
/// | ||
/// use nix::unistd; | ||
/// use nix::sys::stat; | ||
/// use tempdir::TempDir; | ||
/// use tempfile::TempDir; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only use tempfile
or tempfile::tempdir
so it can be uses as tempdir().unwrap()
src/unistd.rs
Outdated
/// | ||
/// fn main() { | ||
/// let tmp_dir = TempDir::new("test_fifo").unwrap(); | ||
/// let tmp_dir = TempDir::new().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tempfile::tempdir().unwrap()
here, same as above
test/sys/test_uio.rs
Outdated
@@ -5,8 +5,7 @@ use std::{cmp, iter}; | |||
use std::fs::{OpenOptions}; | |||
use std::os::unix::io::AsRawFd; | |||
|
|||
use tempdir::TempDir; | |||
use tempfile::tempfile; | |||
use tempfile::{self, tempfile}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use tempfile::{tempdir, tempfile}
no need to import self
test/sys/test_uio.rs
Outdated
@@ -114,7 +113,7 @@ fn test_pwrite() { | |||
fn test_pread() { | |||
use std::io::Write; | |||
|
|||
let tempdir = TempDir::new("nix-test_pread").unwrap(); | |||
let tempdir = tempfile::tempdir().unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With use tempfile::{tempdir, tempfile}
this becomes just tempdir()
Signed-off-by: Igor Gnatenko <[email protected]>
Signed-off-by: Igor Gnatenko <[email protected]>
@bachp fixed. |
Looks good, but needs a CHANGELOG entry under the CHANGED entry with "Increased required Rust version to 1.22.1". Should also update the required version listed in the README. Please do these changes in the last commit. Then LGTM. @asomers anything on your end? |
No, I agree with you, @Susurrus . Just needs a CHANGELOG entry. |
@ignatenkobrain Would you be able to update the CHANGELOG and README and squash that into your last commit? This is otherwise ready to merge. |
Pinging you on this @ignatenkobrain. |
on it. |
Signed-off-by: Igor Gnatenko <[email protected]>
19e420f
to
ecad72a
Compare
done |
bors r+ |
900: deps: update tempfile to 3 r=Susurrus a=ignatenkobrain Signed-off-by: Igor Gnatenko <[email protected]> Co-authored-by: Igor Gnatenko <[email protected]>
Signed-off-by: Igor Gnatenko [email protected]